package panel.viewSpots
{
	import assists.HtmlText;
	import assists.Scale9Grid;
	import assists.TextFieldUtils;
	import assists.resource.ResourceLoader;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.text.TextField;
	
	public class CommentItem extends Sprite
	{
		private var _loader:ResourceLoader;
		private var _stage:Stage;
		
		private var _nameTxt:TextField = new TextField();
		private var _contentTxt:TextField = new TextField();
		private var _timeTxt:TextField = new TextField();
		public function CommentItem(loader:ResourceLoader,stage:Stage)
		{
			_loader = loader;
			_stage = stage;
			init();
		}
		
		private function init():void
		{
			var backGround:Bitmap = _loader.uiManager.generateBmp(_loader.uiManager.weatherBack,true);
			var backGrid:Scale9Grid = new Scale9Grid(backGround.bitmapData,12,12);
			backGrid.width = _stage.stageWidth * 0.96;
			backGrid.height = _stage.stageHeight * 0.2;
			
			_nameTxt.mouseEnabled = false;
			_nameTxt.autoSize = "left";
			_nameTxt.x = backGrid.width * 0.03;
			_nameTxt.y = backGrid.height * 0.02 + backGrid.height * 0.05;
			TextFieldUtils.setHtmlText(_nameTxt,HtmlText.formatSizeColor("用户名",0));
			
			_contentTxt.mouseEnabled = false;
			_contentTxt.autoSize = "left";
			_contentTxt.x = _nameTxt.x;
			_contentTxt.y = 2 * _nameTxt.y + _nameTxt.height;
			
			
			_timeTxt.mouseEnabled = false;
			_timeTxt.autoSize = "left";
			_timeTxt.y = _nameTxt.y;
			TextFieldUtils.setHtmlText(_timeTxt,HtmlText.formatSizeColor("时间",0));
			
			
			this.addChild(backGrid);
			this.addChild(_nameTxt);
			this.addChild(_contentTxt);
			this.addChild(_timeTxt);
		}
		
		public function show(data:Object):void
		{
			TextFieldUtils.setHtmlText(_nameTxt,HtmlText.format(data.userName,0,20,true));
			TextFieldUtils.setHtmlText(_contentTxt,HtmlText.formatSizeColor(data.content,0));
			TextFieldUtils.setHtmlText(_timeTxt,HtmlText.formatSizeColor(data.date,0));
			_timeTxt.x = this.width - _timeTxt.width - _nameTxt.x;
		}
		
	}
}